package com.huluobo.a2203parkdemo.department

import androidx.lifecycle.MutableLiveData
import com.huluobo.base.mvvm.BaseViewModel
import com.huluobo.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import okhttp3.RequestBody
import retrofit2.http.Body
import javax.inject.Inject

/**
 *  Created by LC on 2024/8/7.
 */
@HiltViewModel
class DepartmentViewModel @Inject constructor(
    val apiService: ApiService
) : BaseViewModel() {
    val getAllDepartmentSuccess by lazy { MutableLiveData<String>() }

    fun getAllDepartment(body: RequestBody) {
        executeNetRequest(
            { apiService.getAllDepartment(body) },
            getAllDepartmentSuccess::postValue
        )
    }

    val getDepartmentUserSuccess by lazy { MutableLiveData<String>() }
    val getUnDepartmentUserSuccess by lazy { MutableLiveData<String>() }

    fun getDepartmentUser() {
        executeNetRequest(
            { apiService.getDepartmentUser() },
            getDepartmentUserSuccess::postValue
        )
    }

    fun getUnDepartmentUser() {
        executeNetRequest(
            { apiService.getUnDepartmentUser() },
            getUnDepartmentUserSuccess::postValue
        )
    }

    val addDepartmentSuccess by lazy { MutableLiveData<String>() }

    fun addDepartment(body: RequestBody) {
        executeNetRequest(
            { apiService.addDepartment(body) },
            addDepartmentSuccess::postValue
        )
    }
}